import { contextBridge, ipcRenderer } from 'electron';

contextBridge.exposeInMainWorld('electronAPI', {
  // 平台管理
  getPlatforms: () => ipcRenderer.invoke('get-platforms'),
  addPlatform: (platform: any) => ipcRenderer.invoke('add-platform', platform),
  removePlatform: (platformId: string) => ipcRenderer.invoke('remove-platform', platformId),
  
  // 账号管理
  getAccounts: () => ipcRenderer.invoke('get-accounts'),
  addAccount: (account: any) => ipcRenderer.invoke('add-account', account),
  removeAccount: (accountId: string) => ipcRenderer.invoke('remove-account', accountId),
  
  // 扫码登录
  startQRLogin: (platform: string) => ipcRenderer.invoke('start-qr-login', platform),
  getLoginStatus: (sessionId: string) => ipcRenderer.invoke('get-login-status', sessionId),
  
  // 内置浏览器登录
  openBrowserLogin: (platform: string) => ipcRenderer.invoke('open-browser-login', platform),
  
  // 视频上传
  uploadVideo: (filePath: string, metadata: any) => ipcRenderer.invoke('upload-video', filePath, metadata),
  publishVideo: (videoId: string, platforms: string[]) => ipcRenderer.invoke('publish-video', videoId, platforms),
  
  // 进度监听
  onUploadProgress: (callback: (progress: any) => void) => {
    ipcRenderer.on('upload-progress', (_, progress) => callback(progress));
  },
  onPublishProgress: (callback: (progress: any) => void) => {
    ipcRenderer.on('publish-progress', (_, progress) => callback(progress));
  },
  
  // 打印功能
  print: () => ipcRenderer.invoke('print-page'),
  printToPDF: () => ipcRenderer.invoke('print-to-pdf'),
});
